package com.imau.controller;

import com.imau.service.BrandService;
import com.imau.service.impl.BrandServiceImpl;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;

@WebServlet(name = "BrandDelServlet", value = "/BrandDelServlet")
public class BrandDelServlet extends HttpServlet {
    //服务
    private BrandService service = new BrandServiceImpl();
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        this.doPost(request,response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {


        //获取id
        String id = request.getParameter("id");

        boolean delete = service.delete(Integer.valueOf(id));

        if(delete)
        {
            response.getWriter().write("OK");

        }else {

            response.getWriter().write("ERROR");
        }
    }
}
